home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl5
- #
- # Apps.sdpd.cgi
- #
- # Copyright 1988-1996 Silicon Graphics, Inc.
- # All rights reserved.
- #
- # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- # the contents of this file may not be disclosed to third parties, copied or
- # duplicated in any form, in whole or in part, without the prior written
- # permission of Silicon Graphics, Inc.
- #
- # RESTRICTED RIGHTS LEGEND:
- # Use, duplication or disclosure by the Government is subject to restrictions
- # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- # rights reserved under the Copyright Laws of the United States.
- #
- # $Id: Apps.sdpd.cgi,v 1.20 1997/06/19 22:26:37 shotes Exp $
-
- require "/usr/OnRamp/lib/OnRamp.pm";
- require "ctime.pl";
-
- $myname = "Apps.sdpd.cgi";
- $add_script = "sdr.cgi";
- $announce_dir = "$document_root/apps/sdpd-send";
- $received_dir = "$document_root/apps/sdpd-out";
-
- $set_cookie = 0;
-
- # print "Content-type: text/html\n\n";
- # print "here<br>";
-
- if ($ARGV[0]) { &create_message; }
-
- &get_cookies;
-
- &get_files;
-
- &get_fields;
-
- if (%fld) {
- if ($fld{'get_id'}) { &create_cookie; }
-
- elsif (!$cookie{'sdpd_id'}) { &get_id; }
-
- elsif ($fld{'add'}) {
- print "Content-type: text/html\n\n";
- print "<HTML><HEAD>";
- print "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=$add_script\">";
- print "</HEAD><BODY></BODY></HTML>";
- exit 0;
- }
-
- else {
- $fld{'file'} =~ s/\xa0//g; # get rid of " " characters
- $file = $filename{$fld{'file'}};
-
- if ($fld{'edit'}) {
- $go = $add_script . "?" . $file;
- print "Content-type: text/html\n\n";
- print "<HTML><HEAD>";
- print "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=$go\">";
- print "</HEAD><BODY></BODY></HTML>";
- exit 0;
- }
- else {
- unlink $file;
- &get_files;
- $message = "Announcement \"$fld{'file'}\" deleted.";
- }
-
- }
- }
-
- $javascript =
- "which = \"none\";
- function runSubmit() {
- // onClick gets processed before onSubmit
- if(which == \"select\") return runSelect();
- return (true);
- }
- function markSelect() { which = \"select\"; }
- function markOther() { which = \"none\"; }
- function runSelect() {
- Ctrl = document.page1.file; none = true;
- for(i = 0; i < Ctrl.length; i++) {
- if (Ctrl.options[i].selected) { none = false; break; }
- }
- if(none) {
- errorBox (Ctrl, \"You have not selected an announcement\\nfrom the list.\"); return (false);
- }
- return (true);
- }
- function errorBox (Ctrl, ErrorMessage) {
- alert (ErrorMessage); Ctrl.focus(); return;
- }";
-
- &generic;
-
- sub create_message {
- local($mode) = $ARGV[0];
- local($session_name) = $ARGV[1];
-
- $session_name =~ s/__/ /g;
-
- $message = "Announcement \"$session_name\" ";
- if ($mode eq "e") { $message .= "edited."; }
- else { $message .= "created."; }
- }
-
- sub create_cookie {
- local($time) = time;
-
- $fld{'name'} =~ s/ /#/g;
- $fld{'email'} =~ s/ /#/g;
- $fld{'phone'} =~ s/ /#/g;
-
- $cookie_header = "Content-type: text/html\n"
- . "Set-Cookie: sdpd_id=$time; expires=$date; path=/\n"
- . "Set-Cookie: sdpd_name=$fld{'name'}; expires=$date; path=/\n"
- . "Set-Cookie: sdpd_email=$fld{'email'}; expires=$date; path=/\n"
- . "Set-Cookie: sdpd_phone=$fld{'phone'}; expires=$date; path=/\n\n";
-
- $set_cookie = 1;
- }
-
- sub get_id {
- undef $name, $email, $phone;
-
- print "Content-type: text/html\n\n";
- print "<html><title>Session Directory Manager: User ID</title>";
-
- print "<body bgcolor=#CCC28F background=\"/images/sdr-bg.gif\"\n";
- print "link=#27002B vlink=#00582A text=#800019>\n";
-
- print "<table width=100%>\n";
- print "<tr><th align=left><h1>Personal Information</h1></th>\n";
- print "<th align=right>\n";
- print "<a href=\"/newsplash.shtml\"><img border=0 height=55 width=57 src=\"/apps/home.gif\"></a>\n";
- print " ";
- print "<a href=\"/apps/Apps.shtml\"><img border=0 height=55 width=57 src=\"/apps/back.gif\"></a>\n";
- print "</tr></table>\n";
-
- print "<form action=$add_script method=post>\n";
-
- print "<center><table width=400>\n";
- print qq|<tr><th align=left>Name:</th><td>|,
- &text("sdpd_name","",20),
- qq|</td></tr>\n|;
- print qq|<tr><th align=left>E-mail address:</th><td>|,
- &text("sdpd_email","",20),
- qq|</td></tr>\n|;
- print qq|<tr><th align=left>Telephone number:</th><td>|,
- &text("sdpd_phone","",20),
- qq|</td></tr>\n|;
- print qq|</table><br><br>\n|;
-
- print qq|<input type="submit" name="get_id" value="Submit Information">|;
-
- print qq|</center></form></body></html>|;
-
- exit 0;
- }
-
- sub get_cookies {
- local($a, $b);
- undef %cookie;
- foreach (split(/; /, $ENV{HTTP_COOKIE})) {
- ($a, $b) = split(/=/, $_);
- $cookie{$a} = $b;
- # $message .= "cookie: $a $b<br>";
- }
- }
-
- sub get_files {
- local(@filenames);
-
- if (-e $announce_dir) {
- opendir(DIR, $announce_dir);
- @filenames = readdir(DIR);
- closedir(DIR);
- } else { mkdir($announce_dir, 0755); }
-
- undef @subjects, %filename;
- foreach (@filenames) {
- next if ($_ eq '.' || $_ eq '..');
- $file = $announce_dir . "/" . $_;
- open(IN, $file) || die "Can't open $file";
- $file_id = (split(/\s+/,<IN>))[1];
- if ($file_id eq $cookie{'sdpd_id'}) {
- while(<IN>) {
- @items = split(/=/);
- if ($items[0] eq 's') {
- chop $items[1];
- push(@subjects,$items[1]);
- $filename{$items[1]} = $file;
- }
- }
- }
- close(IN);
- }
- }
-
- sub make_list {
- local(@filenames);
-
- if (-d $received_dir) {
- opendir(DIR, $received_dir);
- @filenames = readdir(DIR);
- closedir(DIR);
- } else { mkdir($received_dir, 0755); }
-
- print "<b><ol>\n";
- $num = 1;
-
- foreach $file (@filenames) {
- next if ($file eq '.' || $file eq '..');
- $file = $received_dir . "/" . $file;
-
- open(IN, $file) || die "Can't open $file";
- $radio = 0;
-
- while(<IN>) {
- chop($_);
-
- if ($_ eq "radio") { $radio = 1; }
- @items = split(/=/,$_);
-
- if ($items[0] eq "s") { $session_name = $items[1]; }
- elsif ($items[0] eq "i") { $session_desc = $items[1]; }
- }
- close(IN);
-
- print "<li><a href=\"#$num\">";
-
- if ($radio) { print $session_desc; }
- else { print $session_name; }
-
- print "</a>\n";
- $num++;
- }
-
- print "</ol></b><hr>\n";
- }
-
- sub make_links {
- local(@filenames);
-
- if (-d $received_dir) {
- opendir(DIR, $received_dir);
- @filenames = readdir(DIR);
- closedir(DIR);
- } else { mkdir($received_dir, 0755); }
-
- $num = 1;
- foreach $file (@filenames) {
- next if ($file eq '.' || $file eq '..');
-
- $url = $ENV{SERVER_URL} . "/apps/sdpd-out/$file?";
-
- $file = $received_dir . "/" . $file;
-
- $mnum = 0;
- undef @mvalue;
- $radio = 0;
- open(IN, $file) || die "Can't open $file";
- while(<IN>) {
- if ($_ eq "radio\n") { $radio = 1; }
- ($a, $b) = split(/=/);
- chop($b);
- if ($a eq "m") { $mvalue[$mnum++] = $b; }
- else { $value{$a} = $b; }
- }
- close(IN);
-
- print "<a name=\"$num\">\n";
-
- print "<table width=100%>\n";
-
- print "<tr><td colspan=3><b>Session:</b> $value{'s'}</td></tr>\n";
- print "<tr><td colspan=3><b>Description:</b> $value{'i'}</td></tr>\n";
- print "<tr><td colspan=3><b>Reference:</b>"
- . "<a href=\"$value{'u'}\">$value{'u'}</a></td></tr>\n";
-
- if ($value{'t'} && $value{'t'} ne "0 0") {
- ($ts, $tf) = split(/\s+/, $value{'t'});
- $ts -= 2208988800; $tf -= 2208988800;
- $date_start = &ctime($ts); $date_finish = &ctime($tf);
- } else { $date_start = ""; }
-
- print "<tr><td rowspan=2 width=50%>";
-
- if ($radio) {
- print "<a href=$url" . "radio>"
- ."<img height=40 width=58 src=\"/images/sdr-radio.gif\"></a>\n";
- } else {
- for ($mnum=0; $mnum<=$#mvalue; $mnum++) {
- $media = (split(/\s+/,$mvalue[$mnum]))[0];
- $media =~ s/whiteboard/wb/;
- $src = "/images/sdr-" . $media . ".gif";
- print "<a href=$url";
- print "$media><img height=40 width=58 src=$src></a>\n";
- print " \n";
- }
- }
-
- print "</td>";
-
- if ($date_start) {
- print "<td align=left><b>Start:</b></td><td align=left>$date_start</td></tr>\n";
- print "<tr align=left><td><b>Finish:</b></td><td align=left>$date_finish</td>\n";
- }
- print "</tr></table><hr>\n";
-
- $num++;
- undef %value;
- }
- }
-
- sub generic {
- print "Content-type: text/html\n\n";
-
- print "<html><head><title>Network Multicast Announcements</title>\n";
- print "<script language=\"JavaScript\">\n";
- print "<!--\n\n$javascript\n\n// -->\n";
- print "</script></head>\n";
- print "<body bgcolor=#CCC28F background=\"/images/sdr-bg.gif\"\n";
- print "link=#27002B vlink=#00582A text=#800019>\n";
-
- print "<table width=100%>\n";
- print "<tr><th align=left><h1>Network Multicast Announcements</h1></th>\n";
- print "<th align=right>\n";
- print "<a href=\"/apps/sdpd_hlp.cgi\"><img border=0 height=65 width=30 src=\"/images/help.gif\"></a>\n";
- print " ";
- print "<a href=\"/newsplash.shtml\"><img border=0 height=55 width=57 src=\"/apps/home.gif\"></a>\n";
- print " ";
- print "<a href=\"/apps/Apps.shtml\"><img border=0 height=55 width=57 src=\"/apps/back.gif\"></a>\n";
- print "</tr></table>\n";
-
- print $message, "<br>\n";
-
- print "<form name=page1 method=post action=$myname onSubmit=\"return runSubmit()\">\n";
-
- print "<table width=600>";
-
- print "<tr><td>";
- print qq|<input type=submit name="add" value="Create New Announcement"|,
- qq| onClick="markOther()">|;
- print "</td></tr>";
-
- if ($#subjects > -1) {
-
- print qq|<tr><td><input type=submit name="edit" value="Edit Selected |,
- qq| Announcement" onClick="markSelect()"></td>|;
- print "<td rowspan=2>";
- print &choice_list(*subjects, "file", 20), "\n";
- print qq|</td></tr><tr><td><input type=submit name="delete" |,
- qq|value="Delete Selected Announcement" onClick="markSelect()">|;
- print "</td></tr>\n";
- }
-
- print "</table></form><hr>";
-
- &make_list;
- &make_links;
-
- print "</body></html>\n";
- }
-